__auther__="YaoJiaWen";


import requests;
from bs4 import BeautifulSoup;
import re;

# 爬取历史上的今天数据
def get_history_news_data(url):
    # 发送请求，获得响应内容
    response = requests.get(url=url);
   # print(response.status_code); # 响应状态码
    # print(response.apparent_encoding); # 通过响应上下文推断编码
    # print(response.text); # 响应文本内容
    # print(response.json()); # 响应的json数据
    # print(response.content); # 响应的二进制数据
    if response.status_code == 200:
        # 根据上下文推断编码，并设置响应编码
        response.encoding = response.apparent_encoding;

    title_list = [];
    content_list = [];
    # 解析响应内容
    bs = BeautifulSoup(markup=response.text, features="html.parser");
    tr_list = bs.find_all(name="tr");
    for tr in tr_list:
        title = tr.find(name="font", attrs={"color":"#ff9933"});
        content = tr.find(name="div", attrs={"style":"MARGIN-left: 10px;MARGIN-top:5px;MARGIN-right: 10px;font-size: 14px;line-height: 20px;"});
        if title:
            title_list.append(title.get_text());
        if content:
            content_list.append(content.get_text());

    return title_list, content_list;


if __name__ == '__main__':
    url = "http://cs.lsqn.cn/";
    get_history_news_data(url);






